unit EnterSum;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ToolEdit, CurrEdit, Mask;

type
  TfmEnterSum = class(TForm)
    edSum: TCurrencyEdit;
    procedure edSumKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function Execute(var ASum: currency): boolean;
    function GetSum: currency;
  end;

var
  fmEnterSum: TfmEnterSum;

implementation

{$R *.DFM}

{ TfmEnterSum }

procedure TfmEnterSum.edSumKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case Key of
    13: ModalResult := mrOk;
    27: ModalResult := mrCancel;
  end;
end;

function TfmEnterSum.Execute(var ASum: currency): boolean;
begin
  edSum.Value := ASum;
  result := (ShowModal = mrOk);
  ASum := edSum.Value;
end;

function TfmEnterSum.GetSum: currency;
begin
  result := edSum.Value;
end;

procedure TfmEnterSum.FormShow(Sender: TObject);
begin
  edSum.SelectAll;
end;

end.
